from tortoise import fields,models

class Goods(models.Model):
    """商品表"""
    id = fields.IntField(pk=True,description='商品ID')
    name = fields.CharField(max_length=200, description='商品名称')
    goods_intro = fields.CharField(max_length=200, description='商品简介')
    category = fields.ForeignKeyField('models.Category', related_name='goods', description='商品分类id')
    goods_cover_img = fields.CharField(max_length=200, description='商品封面图')
    goods_carousel = fields.JSONField(description='商品轮播图')
    goods_details = fields.JSONField(description='商品详情')
    goods_price = fields.DecimalField(max_digits=10, decimal_places=2, description='商品价格')
    selling_price = fields.DecimalField(max_digits=10, decimal_places=2, description='商品实际价格')
    stock_num = fields.IntField(description='商品库存')
    tag = fields.CharField(max_length=200, description='商品标签')
    goods_sell_status = fields.BooleanField(default=True, description='商品上架状态')
    create_time = fields.DatetimeField(auto_now_add=True, description='创建时间')
    update_time = fields.DatetimeField(auto_now=True, description='更新时间')
    create_user = fields.CharField(max_length=255, description='创建人')
    update_user = fields.CharField(max_length=255, description='更新人')

    class Meta:
        table = 'tb_mall_goods'
        table_description = '商品表'

    def __str__(self):
        return self.name

    __repr__ = __str__